//
//  Utils.h
//  PlayMusicTool
//
//  Created by 陈 宏 on 12-6-17.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


typedef enum {
    NONE=0, //没有网络
    IS3G, //3G网络
    ISWIFI,  //
    ERROR //顺序循环
} NetWorkType;


typedef enum {
    WeekType=0,
    MonthType,
}TimeStateType;

@interface Utils : NSObject

+(Utils *)sharesInstance;

+(NSString *)getDefaultFilePathString:(NSString *)fileName;

+(NSString *)getDocumentFilePathString:(NSString *)fileName;

+(NSString *)getLibraryFilePathString:(NSString *)fileName;

+(NSString *)getCacheFilePathString:(NSString *)fileName;

+(NSString *)getCachePathString;

+(NSString *)getTempPathString;

+(NSString *)getTempFilePathString:(NSString *)fileName;

+(NSString *)getResourceFilePathString:(NSString *) resourceName ofType:(NSString*)typeName;

///删除目录下所有文件
+(void)removeFile:(NSString *)folderPath;

//获得存储文件的路径
+ (NSString *)getSaveFilePath:(NSString *)fileName;

///保存文件
+ (void)saveFilePath:(NSString *)filepath fileData:(id)info andEncodeObjectKey:(NSString *)key;
///读取文件
+ (NSData *)loadDataFromFile:(NSString *)fileName anddencodeObjectKey:(NSString *)key;
///获得配置信息
+ (NSString *)loadClientVersionKey:(NSString *)key;

//文件是否存在在某路径下
+ (BOOL)isHaveFileAtPath:(NSString *)path;

//判断文件夹是否存在
+(BOOL)judgeFileExist:(NSString * )fileName;

+(long long) fileSizeAtPath:(NSString*) filePath;
+(long long)folderSize:(const char *)folderPath ;

+(NSInteger)weiBoCountWord:(NSString*)s;
//去掉前后空格
+ (NSString *) getDisposalStr:(NSString *)s;
+ (NSString *)md5:(NSData *)data;

+(BOOL)isEmail:(NSString *)input;
+(BOOL)isMobileNum:(NSString *)input;
+(BOOL)isIdentityCardNo:(NSString *)input;
+(BOOL)isYouBian:(NSString*)input;
/// 判断是不是数字
+(BOOL)isNumber:(NSString *)input;

///  把 毫秒 转为时间 yyyy-mm-dd HH:mm:ss
+ (NSString *)millisecondConvertedToDay:(unsigned long long )time;

+ (NSString *)millisecondToDateByFormatter:(unsigned long long)time formattter:(NSString * ) format;

///  把 秒 转为时间 yyyy-mm-dd HH:mm:ss
+ (NSString *)secondToDateByFormatter:(unsigned long long)time formattter:(NSString * ) format;


///把字符串时间转为指定的格式
+ (NSString *)translateDateString:(NSString *)translateDateString format:(NSString *)format toFormat:(NSString *)tofarmt;
///根据指定日期返回周几 从周日开始，周日为0
+ (NSString *)getWeekdayFromDate:(NSString *)dateStr formatter:(NSString *)matter;

+ (UIImage *)fixOrientation:(UIImage *)aImage;

//修改图片的size
+(UIImage*)scaleToSize:(UIImage*)img size:(CGSize)size;

+(NSString *)ToHex:(long long int)tmpid;
+ (UIColor *) colorWithHexString: (NSString *) stringToConvert;

//得到日期开始和结束时间
+(NSArray *)getStartDayAndEndDay:(TimeStateType)type;

/**
 * @brief 计算字符串的高度.
 *
 * @param  fontSize  字体型号.
 * @param  width  视图的宽度.
 *
 */
+ (CGFloat)heightForString:(NSString *)string fontSize:(float)fontSize andWidth:(float)width;

/**
 * @brief 计算字符串的长度.
 *
 * @param  fontSize  字体型号.
 * @param  height  视图的高度.
 *
 */
+ (CGFloat)widthForString:(NSString *)string fontSize:(float)fontSize andHeight:(float)height;

///将字符串转换为按照指定间隔分隔的字符串
+ (NSString *)translateToCardString:(NSString *)string interval:(NSInteger)interval;

//设置字符串某段字符串的颜色
+(NSMutableAttributedString*)changeStringColor:(NSString*)totleStr changeStr:(NSString *)changeStr changeColor:(UIColor *)changeColor changeFont:(CGFloat)changeFontSize;

///设置一段字符串显示两种颜色
+ (NSAttributedString *)getDifferentColorString:(NSString *)totalStr oneStr:(NSString *)oneStr color:(UIColor *)oneColor otherStr:(NSString *)otherStr ortherColor:(UIColor *)otherColor changeFont:(CGFloat)size;

///设置一段字符串显示两种字体
+ (NSAttributedString *)getDifferentFontString:(NSString *)totalStr oneStr:(NSString *)oneStr font:(UIFont *)oneFont color:(UIColor *)oneColor otherStr:(NSString *)otherStr ortherFont:(UIFont *)otherFont ortherColor:(UIColor *)otherColor;



+ (NSString *)getBankName:(NSString *)bankCode;
+ (NSString *)getBankLogo:(NSString *)bankCode;
+ (NSString *)getBankCardType:(NSString *)bankCardtype;

///将多个字符串的结合，按照指定的间隔符进行分割，拼接成一个字符串
+ (NSString *)stringByStepetorStr:(NSString *)str andInfo:(NSString *)info,...NS_REQUIRES_NIL_TERMINATION;

+ (NSMutableAttributedString *)getLineSpaceString:(NSString *)string lineSpace:(CGFloat)space alignment:(NSTextAlignment)alignment;


///返回一条线
+ (UILabel *)lineLabelWithFrame:(CGRect)frame color:(UIColor *)color;

//UILabel设置文本颜色
+ (NSMutableAttributedString *)setTextColor:(UIColor *)textColor  withRange:(NSRange)textRange withString:(NSString *)string;
+(void)callPeopleBy:(NSString*)call view:(UIView*)view;
#pragma mark-  判断是否包含特殊符号
+(BOOL)checkSepcial:(NSString*)str;
#pragma mark- 改变字符串多处颜色
+(NSMutableAttributedString*)theTotleStr:(NSString*)totleString changedString:(NSArray*)changeArr colorArr:(NSArray*)colorArr font:(UIFont*)font;

/** 判断当前输入的是不是数字*/
+ (BOOL)isNumberInTextField:(UITextField *)startPriceTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
/**
 *计算字符串字数
 */
+ (int)stringCountWord:(NSString*)str;
/**
 *通过字数截取字符串
 */
+ (NSString *)stringAtCount:(int)count string:(NSString *)str;

//身份证号
+ (BOOL) validateIdentityCard: (NSString *)identityCard;
/** MD5 */
+ (NSString *)md5SignStr;

#pragma mark - url转码解码
+ (NSString*)URLDecodedString:(NSString *)str;
+ (NSString *)URLEncodedString:(NSString *)str;
@end
